package models

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Account  string `gorm:"type:varchar(20);not null;unique"`
	Password string `gorm:"type:varchar(30);not null;"`
}

func (u *User) Create() error { //创建
	return DB.Create(&u).Error
}

func (u *User) GetAccountByAccount() error { //根据用户名查询
	return DB.Where("account=?", u.Account).Limit(1).Find(&u).Error
}
